package com.atguigu.gulimall.controller;

import com.atguigu.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;
import java.util.concurrent.TimeUnit;

@RestController

public class SendController {
    @Autowired
    StringRedisTemplate redisTemplate;
    @GetMapping("/sendcode/{phone}")
    public R sendCode(@PathVariable("phone") String phone){
        String code = UUID.randomUUID().toString().substring(0, 5);
        redisTemplate.opsForValue().set(phone,code,5, TimeUnit.MINUTES);
        return  R.ok();
    }

}
